package SpringCloudBase.controller;

import SpringCloudBase.vo.UserVO;
import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.EurekaClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ProviderUserController
 * @Description : 功能说明
 * @Author : LiangT
 * @Date : 2020/3/31 11:48
 */
@RestController
public class ProviderUserController {
    @Autowired
    private EurekaClient eurekaClient;

    @GetMapping("/user/{id}")
    public UserVO getUser(@PathVariable Long id){
        InstanceInfo instanceInfo = eurekaClient.getNextServerFromEureka("PROVIDER-USER",true);
        System.out.println("Provider-User_Url:"+instanceInfo.getHomePageUrl());
        return new UserVO(id);
    }

}
